home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Text⁄Files / FaceLift / FaceLift Folder / FLMaca.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-16  |  8.3 KB  |  314 lines  |  [TEXT/KAHL]

  1. /*
  2.  * FLMaca.h - MacWrite document structures, versions 2.2 and 4.5
  3.  *
  4.  * The comments below are mostly non-edifying.  A copy of
  5.  * Macintosh Technical Notes 11 and 12 is a necessity, as they
  6.  * describe document formats in detail.
  7.  *
  8.  * One difference is that the "active face" in the window variables
  9.  * is really a point size (high byte) and style (low byte), not just
  10.  * a style.    
  11.  */
  12.  
  13.  
  14. # ifndef    _FLMaca_
  15. # define    _FLMaca_
  16.  
  17.  
  18.  
  19. /*
  20.  * Typedef Int16 and Int32 appropriately.  Everything in the Maca
  21.  * project is typed using these to facilitate conversion to other
  22.  * C compilers
  23.  */
  24.  
  25. typedef short    Int16;            /* 16-bit integer */
  26. typedef long    Int32;            /* 32-bit integer */
  27.  
  28.  
  29. typedef enum            /* supported versions of MacWrite */
  30. {
  31.     version3 = 3,        /* MacWrite 2.2 */
  32.     version6 = 6        /* MacWrite 4.5 */
  33. };
  34.  
  35.  
  36. typedef enum            /* document types */
  37. {
  38.     mainDoc = 0,
  39.     headDoc = 1,
  40.     footDoc = 2
  41. };
  42.  
  43.  
  44. typedef enum            /* paragraph types */
  45. {
  46.     rulerPara = 0,
  47.     textPara = 1,
  48.     pictPara = 2
  49. };
  50.  
  51.  
  52. typedef enum            /* justification types */
  53. {
  54.     leftJust = 0,
  55.     centerJust = 1,
  56.     rightJust = 2,
  57.     fillJust = 3
  58. };
  59.  
  60.  
  61. /*
  62.  * Types common to all versions
  63.  */
  64.  
  65. typedef Byte    ByteBool;        /* byte-size boolean */
  66. typedef Byte    UPrintRec[120];    /* 120-byte universal printing record */
  67.                                 /* (anyone know what's in it?) */
  68.  
  69.  
  70. typedef struct Selection
  71. {
  72.     Int16        selPara;    /* selection paragraph number */
  73.     Int16        selPos;        /* selection char position (start or end) */
  74. } Selection;
  75.  
  76.  
  77. typedef struct ActiveFace
  78. {
  79.     Byte        faceSize;    /* point size */
  80.     Byte        faceStyle;    /* style */
  81. } ActiveFace;
  82.  
  83.  
  84. typedef struct Format
  85. {
  86.     Int16        fmtPos;        /* pos of first char format applies to */
  87.     Byte        fmtSize;    /* point size */
  88.     Byte        fmtStyle;    /* style */
  89.     Int16        fmtFont;    /* font number */
  90. } Format;
  91.  
  92.  
  93. typedef struct Ruler
  94. {
  95.     Int16        margLeft;    /* left margin */
  96.     Int16        margRight;    /* right margin */
  97.     Byte        just;        /* justification */
  98.     Byte        nTabs;        /* number of tabs */
  99.     Int16        spacing;    /* line spacing = 1 + (spacing/2) */
  100.     Int16        indent;        /* indentation of first line */
  101.     Int16        tab[10];    /* tab values */
  102.     Byte        fill[4];    /* unused */
  103. } Ruler;
  104.  
  105.  
  106. /*
  107.  * MacWrite 2.2 (version number 3) data structures
  108.  */
  109.  
  110.  
  111. typedef struct Globals3        /* version 2.2 globals */
  112. {
  113.     Int16        version;    /* version number (always 3) */
  114.     Int16        paraOffset;    /* offset to paragraph information */
  115.     Int16        mainParas;    /* main doc paragraph count */
  116.     Int16        headParas;    /* header paragraph count */
  117.     Int16        footParas;    /* footer paragraph count */
  118.     ByteBool    titlePage;    /* title page flag */
  119.     Byte        fill[2];    /* unused */
  120.     ByteBool    showFoot;    /* true if footer displayed */
  121.     ByteBool    showHead;    /* true if header displayed */
  122.     ByteBool    showRuler;    /* true if rulers displayed */
  123.     Int16        activeDoc;    /* active document */
  124.     Int16        startPage;    /* starting page number */
  125. } Globals3;
  126.  
  127.  
  128. typedef struct ParaInfo3
  129. {
  130.     Int16        paraHeight;    /* height of paragraph (pixels) */
  131.     Int16        paraPos;    /* position from top of page */
  132.     Byte        paraPage;    /* page number */
  133.     Byte        fill[3];    /* unused */
  134. } ParaInfo3;
  135.  
  136.  
  137. typedef struct Windows3        /* version 2.2 window variables */
  138. {
  139.     Selection    selStart;    /* start of selection */
  140.     Selection    selEnd;        /* end of selection */
  141.     Int16        vertOffset;    /* vertical offset */
  142.     Int16        redrawPara;    /* first paragraph to redraw */
  143.     Point        pageIconPt;    /* page icon position */
  144.     Point        dateIconPt;    /* date icon position */
  145.     Point        timeIconPt;    /* date icon position */
  146.     Byte        fill[4];    /* unused */
  147.     ByteBool    iconRedraw;    /* true if icons should be redrawn */
  148.     ByteBool    iconFlag;    /* true if rulers shown when icons last drawn */
  149.     Int16        activeFont;    /* font active when saved */
  150.     ActiveFace    activeFace;    /* face active when saved */
  151. } Windows3;
  152.  
  153.  
  154. typedef struct DocInfo3        /* version 2.2 document information */
  155. {
  156.     Globals3    globals3;    /* globals */
  157.     UPrintRec    uPrintRec;    /* universal printing record */
  158.     Windows3    mainWind3;    /* main doc window information */
  159.     Windows3    headWind3;    /* header window information */
  160.     Windows3    footWind3;    /* footer window information */
  161. } DocInfo3;
  162.  
  163.  
  164. /*
  165.  * MacWrite 4.5 (version number 6) data structures
  166.  */
  167.  
  168.  
  169. typedef struct Globals6        /* version 4.5 globals */
  170. {
  171.     Int16        version;    /* version number (always 6) */
  172.     Int16        mainParas;    /* main doc paragraph count */
  173.     Int16        headParas;    /* header paragraph count */
  174.     Int16        footParas;    /* footer paragraph count */
  175.     ByteBool    titlePage;    /* title page flag */
  176.     Byte        fill;        /* unused */
  177.     ByteBool    showScrap;    /* true if scrap displayed */
  178.     ByteBool    showFoot;    /* true if footer displayed */
  179.     ByteBool    showHead;    /* true if header displayed */
  180.     ByteBool    showRuler;    /* true if rulers displayed */
  181.     Int16        activeDoc;    /* active document */
  182.     Int16        startPage;    /* starting page number */
  183.     Int32        freePos;    /* free list position */
  184.     Int16        freeLen;    /* free list length */
  185.     Int16        freeAlloc;    /* bytes allocated for free list on disk */
  186.     Byte        fill2[14];    /* unused */
  187. } Globals6;
  188.  
  189.  
  190. typedef enum                /* status byte bitmasks */
  191. {
  192.     stJustMask = 0x03,        /* justification code */
  193.     stInUse = 0x04,            /* bit set if paragraph is in use */
  194.     stCompress = 0x08,        /* bit set if text is compressed */
  195.     stOnItsWay = 0x10,        /* bit set if disk i/o started, not done */
  196.     stInMemory = 0x20,        /* bit set if paragraph is in memory */
  197.     stJustify = 0x40,        /* bit set if just code above used */
  198.                             /* otherwise use ruler */
  199.     stDirty = 0x80            /* set if paragraph is dirty */
  200. };
  201.  
  202.  
  203. typedef enum            /* justification codes relating to stJustMask */
  204. {
  205.     stJustLeft = 0x00,
  206.     stJustCenter = 0x01,
  207.     stJustRight = 0x02,
  208.     stJustFull = 0x03
  209. };
  210.  
  211.  
  212. typedef union ParaStOff
  213. {
  214.     Byte        paraStatus;    /* paragraph status */
  215.     Int32        paraOffset;    /* position of paragraph data */
  216.                             /* (low 3 bytes only) */
  217. } ParaStOff;
  218.  
  219.  
  220. typedef struct ParaInfo6
  221. {
  222.     Int16        paraHeight;    /* height of paragraph (pixels) */
  223.     Int16        paraPos;    /* position from top of page */
  224.     Int32        paraHandle;    /* handle to paragraph */
  225.     ParaStOff    paraStOff;    /* data position/status */
  226.     Int16        paraLen;    /* length of paragraph data */
  227.     Int16        paraFmts;    /* common formats */
  228. } ParaInfo6;
  229.  
  230. typedef ParaInfo6    InfoArray6[1];    /* used as variable-length */
  231.  
  232.  
  233. typedef struct Windows6        /* version 4.5 window variables */
  234. {
  235.     Selection    selStart;    /* start of selection */
  236.     Selection    selEnd;        /* end of selection */
  237.     Int16        vertOffset;    /* vertical offset */
  238.     Int16        redrawPara;    /* first paragraph to redraw */
  239.     Int32        infoPos;    /* position of information array */
  240.     Int16        infoLen;    /* length of information array */
  241.     Int32        linePos;    /* position of line height array */
  242.     Int16        lineLen;    /* length of line height array */
  243.     Point        pageIconPt;    /* page icon position */
  244.     Point        dateIconPt;    /* date icon position */
  245.     Point        timeIconPt;    /* date icon position */
  246.     Byte        fill[4];    /* unused */
  247.     ByteBool    iconRedraw;    /* true if ovals (icons) should be redrawn */
  248.     ByteBool    iconFlag;    /* true if rulers shown when ovals last drawn */
  249.     ActiveFace    activeFace;    /* face active when saved */
  250.     Int16        activeFont;    /* font active when saved */
  251. } Windows6;
  252.  
  253.  
  254. typedef struct DocInfo6        /* version 4.5 document information */
  255. {
  256.     Globals6    globals6;    /* globals */
  257.     UPrintRec    uPrintRec;    /* universal printing record */
  258.     Windows6    footWind6;    /* footer window information */
  259.     Windows6    headWind6;    /* header window information */
  260.     Windows6    mainWind6;    /* main doc window information */
  261. } DocInfo6;
  262.  
  263.  
  264. /*
  265.  * External definitions
  266.  */
  267.  
  268.  
  269. /*
  270.  * File variables
  271.  */
  272.  
  273.  
  274. extern Int16        macaFRef;        /* file descriptor */
  275. extern Str255        macaName;        /* file name */
  276. extern Int16        macaRefNum;        /* volume reference number */
  277. extern Int32        paraFilePos;    /* position of last paragraph read */
  278.  
  279. extern Int16        version;
  280. extern Int16        paraOffset;
  281. extern Int16        mainParas;
  282. extern Int16        headParas;
  283. extern Int16        footParas;
  284.  
  285. extern Int32        infoPos;
  286. extern Int16        infoLen;
  287.  
  288. extern Windows3        *headWind3, *footWind3, *mainWind3;
  289. extern Windows6        *headWind6, *footWind6, *mainWind6;
  290.  
  291. extern DocInfo3    docInfo3;
  292. extern DocInfo6    docInfo6;
  293.  
  294. extern Handle    paraBuf;        /* buffer for contents of paragraph */
  295. extern Int16    totalParas;        /* total paragraphs in document */
  296. extern Int16    paraNum;        /* current paragraph number */
  297. extern Int16    paraDocType;    /* whether main, header or footer para */
  298. extern Int16    paraType;        /* paragraph type (text, ruler, picture) */
  299. extern Int16    paraLen;        /* paragraph length */
  300. extern Int16    textLen;        /* length of text in text paragraphs */
  301. extern Int16    formats;        /* number of formats in text paragraph */
  302. extern Int16    fmtOffset;        /* offset w/in text paragraph to formats */
  303. extern InfoArray6    **paraInfo6;    /* info array (for version 6 only) */
  304.  
  305.  
  306. /*
  307.  * Functions returning non-int
  308.  */
  309.  
  310. Boolean    OpenMaca ();
  311. Boolean    ReadPara ();
  312.  
  313. # endif
  314.